<?php

/**
 * Sets up the inital BillboardCE table structure
 *
 */
class Db_004_bbce_initial_table_structure extends Ot_Migrate_Migration_Abstract
{
    public function up($dba)
    {
        $query = "
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_option` (
                  `moduleName` varchar(128) NOT NULL,
                  `type` enum('slide','slidestream') NOT NULL,
                  `status` enum('enabled','disabled') NOT NULL,
                  PRIMARY KEY (`moduleName`,`type`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_option`
                --
                
                INSERT INTO `" . $this->tablePrefix . "tbl_plugin_option` (`moduleName`, `type`, `status`) VALUES
                ('Impression', 'slide', 'disabled'),
                ('Marquee', 'slidestream', 'enabled'),
                ('Schedule', 'slide', 'enabled'),
                ('Transition', 'slide', 'disabled');
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slideoption_impression`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slideoption_impression` (
                  `slideId` int(10) unsigned NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slideoption_impression`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slideoption_schedule`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slideoption_schedule` (
                  `slideId` int(10) unsigned NOT NULL,
                  `fromDt` int(10) unsigned NOT NULL,
                  `toDt` int(10) unsigned NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slideoption_schedule`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slideoption_transition`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slideoption_transition` (
                  `slideId` int(11) NOT NULL,
                  `transition` varchar(64) NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slideoption_transition`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidestreamoption_marquee`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidestreamoption_marquee` (
                  `slideStreamId` int(10) unsigned NOT NULL,
                  `enabled` int(1) NOT NULL,
                  `type` enum('text','rss','custom') NOT NULL,
                  `text` text NOT NULL,
                  `url` varchar(255) NOT NULL,
                  `position` enum('bottom','top') NOT NULL,
                  `textColor` varchar(6) NOT NULL DEFAULT 'FFFFFF',
                  `bgColor` varchar(6) NOT NULL DEFAULT '000000',
                  `opacity` varchar(4) NOT NULL DEFAULT '1',
                  `effect` enum('roll','crawl') NOT NULL DEFAULT 'roll',
                  PRIMARY KEY (`slideStreamId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidestreamoption_marquee`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype` (
                  `moduleName` varchar(128) NOT NULL,
                  `type` enum('slide') NOT NULL,
                  `status` enum('enabled','disabled') NOT NULL,
                  PRIMARY KEY (`moduleName`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype_flv`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype_flv` (
                  `slideId` int(11) NOT NULL,
                  `url` text CHARACTER SET utf8 NOT NULL,
                  `mute` tinyint(1) NOT NULL,
                  `volume` int(3) NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype_flv`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype_image`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype_image` (
                  `slideId` int(11) NOT NULL,
                  `url` text CHARACTER SET utf8 NOT NULL,
                  `bgColor` varchar(6) NOT NULL,
                  `alignment` enum('topLeft','topCenter','topRight','centerLeft','centerCenter','centerRight','bottomLeft','bottomCenter','bottomRight') CHARACTER SET utf8 NOT NULL DEFAULT 'centerCenter',
                  `scaling` enum('none','up','down','fill') NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype_image`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype_url`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype_url` (
                  `slideId` int(11) NOT NULL,
                  `url` text CHARACTER SET utf8 NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype_url`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype_visibletweets`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype_visibletweets` (
                  `slideId` int(11) NOT NULL,
                  `query` varchar(128) NOT NULL,
                  `animation` tinyint(1) NOT NULL DEFAULT '1'
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype_visibletweets`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_plugin_slidetype_youtube`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_plugin_slidetype_youtube` (
                  `slideId` int(10) unsigned NOT NULL,
                  `videoId` varchar(64) NOT NULL,
                  `mute` tinyint(1) NOT NULL DEFAULT '0',
                  `volume` int(3) NOT NULL DEFAULT '75'
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_plugin_slidetype_youtube`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_slide`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_slide` (
                  `slideId` int(10) unsigned NOT NULL AUTO_INCREMENT,
                  `title` varchar(255) CHARACTER SET utf8 NOT NULL,
                  `slideType` varchar(16) NOT NULL,
                  PRIMARY KEY (`slideId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=ucs2 AUTO_INCREMENT=1 ;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_slide`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_slide_stream`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_slide_stream` (
                  `slideStreamId` int(10) unsigned NOT NULL AUTO_INCREMENT,
                  `accountId` int(10) unsigned NOT NULL,
                  `title` varchar(255) NOT NULL,
                  `updateTimestamp` int(11) NOT NULL,
                  PRIMARY KEY (`slideStreamId`),
                  KEY `accountId` (`accountId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
                
                --
                -- Dumping data for table `" . $this->tablePrefix . "tbl_slide_stream`
                --
                
                
                -- --------------------------------------------------------
                
                --
                -- Table structure for table `" . $this->tablePrefix . "tbl_slide_stream_map`
                --
                
                CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_slide_stream_map` (
                  `slideStreamMapId` int(10) unsigned NOT NULL AUTO_INCREMENT,
                  `slideStreamId` int(10) unsigned NOT NULL,
                  `entityType` enum('slide','slideStream') NOT NULL,
                  `entityTypeId` int(10) unsigned NOT NULL,
                  `order` int(10) unsigned NOT NULL,
                  `displayLength` int(10) unsigned NOT NULL DEFAULT '5' COMMENT 'Display length in seconds',
                  PRIMARY KEY (`slideStreamMapId`),
                  KEY `slideStreamId` (`slideStreamId`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Maps slides and slide streams to slide streams' AUTO_INCREMENT=1 ;
        ";
        
        $dba->query($query);
    }

    public function down($dba) {
        
    }    
}